//
//  HXGridScreenViewController.m
//  HongxuanBluetooth
//
//  Created by 广州弘轩科技发展有限公司 on 2023/8/14.
//

#import "HXGridScreenViewController.h"

@interface HXGridScreenViewController ()
@property (strong,nonatomic) UIImageView *formview;
@property (strong,nonatomic) UILabel *timelb;
@property (assign,nonatomic) NSInteger indexValue;//记录点击成功下标
@property (assign,nonatomic) NSInteger tenHour;//24小时制十位。tenHour
@property (assign,nonatomic) NSInteger unitHour;//24小时制个位。unitHour
@property (assign,nonatomic) NSInteger tenMinute;//24小时制十分位。tenMinute

@property (strong,nonatomic) NSString *ultimateTime; //最终的时间;
@property (strong, nonatomic) BlueToothManager *blueToothManager;//蓝牙
@property (strong,nonatomic) UIImageView *blackview;

@property (strong,nonatomic)  NSTimer* vibrationTimer;//震动计时器
@property (assign,nonatomic) BOOL isArrive;//是否到达
@end

@implementation HXGridScreenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blackColor];
    self.fd_prefersNavigationBarHidden = YES;
    self.indexValue = 1;
    self.blueToothManager = [BlueToothManager shareInstance];
    [self.blueToothManager StartScan];//打开蓝牙
    UIImageView *tabr = [[UIImageView alloc] initWithFrame:CGRectMake(0, kNavHeight-44, winWidth, 44)];
//    tabr.backgroundColor = [UIColor yellowColor];
    NSLog(@"winHeight:%f winWidth:%f",winHeight,winWidth);
    [self.view addSubview:tabr];
    UIImageView *mainscreen = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, winWidth, 44)];
    mainscreen.image = [UIImage imageNamed:@"solodemomian"];
    [tabr addSubview:mainscreen];
    
    UIButton *hidebt = [UIButton buttonWithType:UIButtonTypeCustom];
//    hidebt.backgroundColor = [UIColor whiteColor];
    [hidebt addTarget:self action:@selector(breathingPlate) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:hidebt];
    [hidebt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(tabr.mas_bottom);
        make.right.mas_equalTo(0);
        make.width.height.mas_equalTo(70);
    }];
    
    
    UILabel *timelb = [[UILabel alloc] init];
    timelb.textAlignment = NSTextAlignmentCenter;
    if(self.bluetoothTime.length>0){
        timelb.text = self.bluetoothTime;
    }else{
        timelb.text = @"00:00";
    }
    
    timelb.textColor = [UIColor whiteColor];
    timelb.font = [UIFont systemFontOfSize:90];
    [self.view addSubview:timelb];
    self.timelb = timelb;
     [timelb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(69);
        make.right.mas_equalTo(-69);
        make.top.mas_equalTo(tabr.mas_bottom).offset(37+44);
        make.height.mas_equalTo(68);
    }];
    
    
    self.formview  = [[UIImageView alloc] init];
    self.formview.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.formview];
    [self.formview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(timelb.mas_bottom).offset(35);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(-33-SafeAreaBottomHeight);
    }];
    NSLog(@"%f :%f",self.formview.bounds.size.width,self.formview.bounds.size.height);
    [self addform];
    
    UIImageView *blackview = [[UIImageView alloc] init];
    blackview.backgroundColor = [UIColor blackColor];
    blackview.hidden = YES;
    self.blackview = blackview;
    [self.view addSubview:blackview];
    [blackview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.view);
    }];
    WeakSelf
    self.blueToothManager.datalasttimeBlock = ^(NSString * _Nonnull lasttime) {
        NSLog(@"获取设备返回来数据:%@",lasttime);
        NSArray *Arr = [NSArray array];
        Arr = [lasttime componentsSeparatedByString:@"0x585703"];
//        NSLog(@"获取最后的时间：%@",Arr);
        NSString *time = [Arr[1] substringWithRange:NSMakeRange(8, 2)];
        NSLog(@"time ：%@",time);
        if([time isEqualToString:@"02"]){
            [weakSelf stopvibration];//暂停震动
        }
        
    };
    self.blueToothManager.ConnectionFailureBlock = ^(NSString * _Nonnull uuid) {
//        断开了链接
        NSLog(@"断开了链接。。。。");
        [[NSNotificationCenter defaultCenter]postNotificationName:@"bluetoothDisconnect" object:nil userInfo:@{@"uuid":uuid}];
        [weakSelf stopvibration];
        [weakSelf.blueToothManager StartScan];//打开蓝牙
        [weakSelf stopvibration];//暂停震动
    };
    
    self.blueToothManager.successfulConnectionBlock = ^(NSMutableArray * _Nonnull list) {
        NSLog(@"list %@",list);
        NSLog(@"链接成功");
//        [weakSelf resendTime];
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
           // 在子线程中执行需要延时的代码
           [NSThread sleepForTimeInterval:1.0]; // 休眠0.8秒钟

           dispatch_async(dispatch_get_main_queue(), ^{
              // 回到主线程中执行剩余操作

//               [weakSelf resendTime];
           });
        });
        [[NSNotificationCenter defaultCenter]postNotificationName:@"linkSuccess" object:nil userInfo:@{@"list":list}];
    };

}
-(void)addform{
    //自定义宫格边
    
    NSArray *imagearry = @[@"number1",@"number2",@"number3",@"number4",@"number5",@"number6",@"number7",@"number8",@"number9",@"number10",@"number11",@"number12"];
    
    NSInteger tag = 100;
    for (NSInteger i = 0; i < 4; i ++) {
        for (NSInteger j = 0; j < 3; j ++) {
            CGFloat btnW =  (winWidth-30)/3.00;
            CGFloat btnH = (winHeight-33-SafeAreaBottomHeight-35-68-37-44-kNavHeight)/4.0;
            CGFloat  btnX = j*btnW;
            CGFloat btnY = i*btnH;
            
            UIImageView *numeview = [[UIImageView alloc] initWithFrame:CGRectMake(btnX, btnY, btnW, btnH)];
            numeview.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",imagearry[tag-100]]];
            self.formview.userInteractionEnabled = YES;
            numeview.userInteractionEnabled = YES;
            [self.formview addSubview:numeview];
            
            UIButton *one = [UIButton buttonWithType:UIButtonTypeCustom];
            one.frame = CGRectMake(btnX, btnY, btnW, btnH);
            one.tag = tag ++;
            
            [self.formview addSubview:one];
            [one addTarget:self action:@selector(nuber:) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    
    

}
-(void)nuber:(UIButton *)button{
//    NSLog(@"%lu",(unsigned long)self.timelb.text.length);
//    NSLog(@"打印了:%ld",(long)button.tag);
//    NSString *dateStr = [NSString stringWithFormat:@"(按月还息到期还本,限期 %.0d 月)",[borrow_period intValue]]; //borrow_period是从后台获取到的数据字段
//    NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:dateStr];
//    [mutAttStr addAttribute:NSForegroundColorAttributeName value:ACCOUNT_BG_COLOR range:NSMakeRange(13,1)]; //根据具体字符串的内容来设置具体部分的颜色
//    label.attributedText = mutAttStr;
    if(button.tag == 111){
        NSLog(@"点击了空白");
/*
//        [self.navigationController popViewControllerAnimated:YES];
        NSArray *array = [self.ultimateTime componentsSeparatedByString:@":"];
        NSString * time = [NSString stringWithFormat:@"%@",array[0]];
        NSString * hour = [NSString stringWithFormat:@"%@",array[1]];
        int data = time.intValue;
        int tow = hour.intValue;
        NSLog(@"%d",data);
        data = [XHbluetoolUtils intTransitionhex16:data];
        tow = [XHbluetoolUtils intTransitionhex16:tow];
        Byte send[] = {0x58,0x57,0x03,0x0B,0x00,data,tow,0x01};
        NSData *sendData = [NSData dataWithBytes:&send length:sizeof(send)];

        [self.blueToothManager writeData:sendData];
        */
        
        return;
    }
    if(button.tag == 109){
        NSLog(@"点击了x");
//        NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:@"00:00"];
//        [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,5)]; //根据具体字符串的内容来设置具体部分的颜色
//        self.timelb.attributedText = mutAttStr;
        self.indexValue = 1;
        self.tenHour = 0;
        self.timelb.text = @"00:00";
        self.timelb.textColor = [UIColor whiteColor];
        
        return;
    }
    //时间24小时制
    
    if(self.indexValue == 1){//第一次按钮
        //如果第一次点击，100 = 1  101 = 2  110 = 0 对应的按钮 那就是第一个位置
//        第一次点击了0 1 2 那就是24小时制第一个位置。
        if(button.tag == 100||button.tag == 101||button.tag == 110){
            NSString *time;
            if(button.tag == 110){//点击了0
                self.tenHour = 0;
                time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"0"];
                NSLog(@"time :%@",time);
            }else{
                time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
                self.tenHour = button.tag-99;
                NSLog(@"time :%@",time);
            }

            NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:time];
            [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,1)]; //根据具体字符串的内容来设置具体部分的颜色
            self.timelb.attributedText = mutAttStr;
//            self.timelb.text = time;
            
            self.indexValue = 2;//第一个没问题
            
            return;
            
        }else{
            NSString *time;
            //24小时制，如果第一个点击不是0 1 2  第一位那就是 0；
            time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"0"];
            self.timelb.text = [time stringByReplacingCharactersInRange:NSMakeRange(1, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
            
            NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:self.timelb.text];
            [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,2)]; //根据具体字符串的内容来设置具体部分的颜色
            self.timelb.attributedText = mutAttStr;
            self.indexValue = 3;//第一个
            self.tenHour = 0;
            return;
        }
        
    }
//    第二次点击 已经知道第一个是0 1 2
    if(self.indexValue == 2){
        NSLog(@"self.tenHour :%ld",self.tenHour);
//        如果第一个十位 是0 1 个位0-9都可以
        if(self.tenHour ==0 ||self.tenHour == 1){
            if(button.tag == 110){
                self.timelb.text = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(1, 1) withString:@"0"];
            }else{
                self.timelb.text = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(1, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
            }
            
            NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:self.timelb.text];
            [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,2)]; //根据具体字符串的内容来设置具体部分的颜色
            self.timelb.attributedText = mutAttStr;
            
            self.indexValue = 3;
            self.unitHour = button.tag-99;
            return;
        }
        
        if(self.tenHour == 2){
            if(button.tag == 110 || button.tag == 100 || button.tag == 101|| button.tag == 102){
                NSString *time;
                if(button.tag == 110){//点击了0
                    self.unitHour = 0;
                    time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(1, 1) withString:@"0"];
                    NSLog(@"time :%@",time);
                }else{
                    time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(1, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
                    self.unitHour = button.tag-99;
                    NSLog(@"time :%@",time);
                }
                NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:time];
                [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,2)]; //根据具体字符串的内容来设置具体部分的颜色
                self.timelb.attributedText = mutAttStr;
//                self.timelb.text = time;
                self.indexValue = 3;
                return;
            }else{
                NSLog(@"小时十位是2 个位不能是%ld",button.tag-99);
            }
        }
       
    }
    
    if(self.indexValue == 3){//第三个数字
        NSLog(@"第三个数字 十分位置是：%ld",button.tag-99);
//        十分位tenMinute  最多
        if(button.tag == 100||button.tag == 101||button.tag == 102||button.tag == 103||button.tag == 104||button.tag == 110){
            NSString *time;
            if(button.tag == 110){//点击了0
                
                time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(3, 1) withString:@"0"];
                
            }else{
                time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(3, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
                //            self.timelb.text = time;
            }
            NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:time];
            [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,4)]; //根据具体字符串的内容来设置具体部分的颜色
            self.timelb.attributedText = mutAttStr;
            
            self.tenMinute = button.tag-99;
            self.indexValue = 4;
            return;
            NSLog(@"time :%@",time);
        }else{
            NSLog(@"十分位不能是：%ld",button.tag-99);
        }
        
    }
    if(self.indexValue == 4){
        
        NSString *time;
        if(button.tag == 110){//点击了0
            
            time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(4, 1) withString:@"0"];
            
        }else{
            time = [self.timelb.text stringByReplacingCharactersInRange:NSMakeRange(4, 1) withString:[NSString stringWithFormat:@"%ld",button.tag-99]];
        }
            NSLog(@"time :%@",time);
        NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:time];
        [mutAttStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,5)]; //根据具体字符串的内容来设置具体部分的颜色
        self.timelb.attributedText = mutAttStr;
        
//            self.timelb.text = time;
        
            self.indexValue = 5;
            self.ultimateTime = self.timelb.text;
            [self sendingBluetoothTime];//发送给蓝牙
            return;
    }
    
    
}

-(void)sendingBluetoothTime{
    
//    self.ultimateTime

    //从字符d中分隔成2个元素的数组
    NSArray *array = [self.ultimateTime componentsSeparatedByString:@":"];
    NSString * time = [NSString stringWithFormat:@"%@",array[0]];
    NSString * hour = [NSString stringWithFormat:@"%@",array[1]];
    int data = time.intValue;
    int tow = hour.intValue;
    NSLog(@"%d",data);
    if(data>12){
        data = data - 12;
    }
    data = [XHbluetoolUtils intTransitionhex16:data];
    tow = [XHbluetoolUtils intTransitionhex16:tow];
    Byte send[] = {0x58,0x57,0x03,0xff,0x00,data,tow,0x01};
    NSData *sendData = [NSData dataWithBytes:&send length:sizeof(send)];
    NSLog(@"self.ultimateTime :%@",self.ultimateTime);
    [self.blueToothManager writeData:sendData];
    
    if(data<10){
        self.ultimateTime = [NSString stringWithFormat:@"0%d:%@",data,hour];
    }else{
        self.ultimateTime = [NSString stringWithFormat:@"%d:%@",data,hour];
    }
    //    存入蓝牙时间
    [[NSUserDefaults standardUserDefaults] setObject:self.ultimateTime forKey:@"Bluetoothtime"];
    //这里建议同步存储到磁盘中，但是不是必须的
    [[NSUserDefaults standardUserDefaults] synchronize];
    if (self.bluetoothtimeBlock) {
        self.bluetoothtimeBlock(self.ultimateTime);
    }
//    震动
//    if (@available(iOS 10.0, *)) {
//        UINotificationFeedbackGenerator *generator = [[UINotificationFeedbackGenerator alloc] init];
//        [generator notificationOccurred:UINotificationFeedbackTypeWarning];
//    }
//    if(@available(iOS 10.0, *)){
//            UIImpactFeedbackGenerator *impactFeedBack = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleMedium];
//            [impactFeedBack prepare];
//            [impactFeedBack impactOccurred];
//        }
//    AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate, nil);
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
       // 在子线程中执行需要延时的代码
//        AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate, nil);
       [NSThread sleepForTimeInterval:0.5]; // 休眠0.8秒钟

       dispatch_async(dispatch_get_main_queue(), ^{
          // 回到主线程中执行剩余操作
           [self getdataobtainrotationalstate];
           [self resettime];//重置时间
           
       });
    });
        
}
- (void)getdataobtainrotationalstate{
    if(self.blueToothManager.connectionState){
        NSLog(@"链接状态");
    }else{
        NSLog(@"未链接状态");
        NSLog(@"%@",self.ultimateTime);
        //    存入蓝牙时间
        [[NSUserDefaults standardUserDefaults] setObject:self.ultimateTime forKey:@"untraveledTime"];
        //这里建议同步存储到磁盘中，但是不是必须的
        [[NSUserDefaults standardUserDefaults] synchronize];
        return;
    }
    if(self.blueToothManager.bluetoothDiscoverable){
        NSLog(@"bluetoothDiscoverable链接状态");
    }else{
        NSLog(@"bluetoothDiscoverable 未链接状态 %@",self.ultimateTime);
        //    存入蓝牙时间
        [[NSUserDefaults standardUserDefaults] setObject:self.ultimateTime forKey:@"untraveledTime"];
        //这里建议同步存储到磁盘中，但是不是必须的
        [[NSUserDefaults standardUserDefaults] synchronize];
        return;
    }
    [self.vibrationTimer invalidate];
//    self.vibrationTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(playkSystemSound) userInfo:nil repeats:YES];
    Byte send[] = {0x58,0x57,0x03,0x0B,0x0,0x00,0x00,0x03};
    NSData *sendData = [NSData dataWithBytes:&send length:sizeof(send)];
    [self.blueToothManager writeData:sendData];
    
//    centralManager
    AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate, nil);

    self.vibrationTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(playkSystemSound) userInfo:nil repeats:YES];
    
}
- (void)playkSystemSound{
//    获取现在是否走的，返回02就是走到正常的时间
    Byte send[] = {0x58,0x57,0x03,0x0B,0x0,0x00,0x00,0x08};
    NSData *sendData = [NSData dataWithBytes:&send length:sizeof(send)];
//    [self.blueToothManager writeData:sendData];
    [[BlueToothManager shareInstance] writeData:sendData];
    
//    AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate, nil);
}

- (void)stopvibration{
    [self.vibrationTimer invalidate];
}
- (void)resettime{
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
       // 在子线程中执行需要延时的代码
       [NSThread sleepForTimeInterval:0.8]; // 休眠0.8秒钟

       dispatch_async(dispatch_get_main_queue(), ^{
          // 回到主线程中执行剩余操作
           self.indexValue = 1;
           self.tenHour = 0;
           self.timelb.text = @"00:00";
           self.ultimateTime = @"00:00";
           self.timelb.textColor = [UIColor whiteColor];
       });
    });
    
//    self.indexValue = 1;
//    self.tenHour = 0;
//    self.timelb.text = @"00:00";
//    self.ultimateTime = @"00:00";
//    self.timelb.textColor = [UIColor whiteColor];
}
-(void)breathingPlate{
    NSLog(@"点击息屏");
    
    if(self.blackview.hidden){
        self.blackview.hidden = NO;
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES]; //状态栏白色
    }else{
        self.blackview.hidden = YES;
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; //状态栏白色
    }
    
}
- (void)dealloc{
    if(self.isArrive){
        NSLog(@"跑到对应的时间");
    }else{
        NSLog(@"没跑到对应的时间");
        //    存入蓝牙时间
        [[NSUserDefaults standardUserDefaults] setObject:self.ultimateTime forKey:@"untraveledTime"];
        //这里建议同步存储到磁盘中，但是不是必须的
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    [self stopvibration];
}
- (void)resendTime{
    
    //    存入蓝牙时间NSString *arr= [[NSUserDefaults standardUserDefaults] objectForKey:@"theme"];
    NSString *resendTime= [[NSUserDefaults standardUserDefaults] objectForKey:@"untraveledTime"];
    NSLog(@"resendTime :%@",resendTime);
    if(kStringIsEmpty(resendTime)||[resendTime isEqualToString:@"无"]){
        NSLog(@"显示无。");
        return;
    }
    NSArray *array = [resendTime componentsSeparatedByString:@":"];
    NSString * time = [NSString stringWithFormat:@"%@",array[0]];
    NSString * hour = [NSString stringWithFormat:@"%@",array[1]];
    int data = time.intValue;
    int tow = hour.intValue;
    NSLog(@"%d",data);
    data = [XHbluetoolUtils intTransitionhex16:data];
    if(data>12){
        data = data - 12;
    }
    
    NSLog(@"12进制时间：%d",data);
    tow = [XHbluetoolUtils intTransitionhex16:tow];
    Byte send[] = {0x58,0x57,0x03,0xff,0x00,data,tow,0x01};
    NSData *sendData = [NSData dataWithBytes:&send length:sizeof(send)];
    self.isArrive = NO;//发送时no 到指定位置折为yes
    [self.blueToothManager writeData:sendData];
    
    [[NSUserDefaults standardUserDefaults] setObject:@"无" forKey:@"untraveledTime"];
    //这里建议同步存储到磁盘中，但是不是必须的
    [[NSUserDefaults standardUserDefaults] synchronize];
    //    存入蓝牙时间
    [[NSUserDefaults standardUserDefaults] setObject:resendTime forKey:@"Bluetoothtime"];
    //这里建议同步存储到磁盘中，但是不是必须的
    [[NSUserDefaults standardUserDefaults] synchronize];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

*/

@end
